<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>前段登录</title>
</head>
<body>
<form action="abc.php" method="post" id="formname">
  卡号：<input name="cardNo" id="cardNo" placeholder="请输入卡号"onblur="checkCardNo()"
  type="text"><span id="spanCardNo"></span><br>
  <!--卡号：<input name="cardNo" id="cardNo" placeholder="请输入卡号"onblur="checkCardNo()"-->
  <!--type="text"><span id="spanCardNo"></span><br>-->
  <input type="button" value="提交" onclick="check()">
</form>
<script type="text/javascript">
  function checkCardNo(){
    cardNo = document.getElementById("cardNo").value;
    document.getElementById("spanCardNo").innerHTML="";
    if(cardNo==""||cardNo==null){
      document.getElementById("checkCardNo").innerHTML = "卡号不可以为空";
      return false;
    }else {
      if(cardNo.length!=10){
        document.getElementById("spanCardNo").innerHTML = "卡号必须为十位数";
        return false;
      }
      if(parseInt(cardNo).toString().length!=10){
        document.getElementById("spanCardNo").innerHTML = "卡号必须为十位数字，不能以0开头";
        return false;
      }
    }
    return true;
  }
  function check(){
    if(checkCardNo()){
        document.getElementById("formname").submit();
      }else{
      alert("账号密码错误");
      return false;
    }
  }
</script>
</body>
</html>
